<?php
class DomBrowserTestCase extends UnitTestCase {
	
	public function testIsSearchEngineBot() {
		
		$this->assertFalse( DomBrowser::isSearchEngineBot(), 'Thinks we are search engine bot!');
		
		$userAgentCache = $_SERVER['HTTP_USER_AGENT'];
		$_SERVER['HTTP_USER_AGENT'] = 'googlebot';
		$this->assertTrue( DomBrowser::isSearchEngineBot(), 'Didn\'t reconize bot!');
		
		$_SERVER['HTTP_USER_AGENT'] = 'froogle';
		$this->assertTrue( DomBrowser::isSearchEngineBot(), 'Didn\'t reconize bot!');
		
		$_SERVER['HTTP_USER_AGENT'] = $userAgentCache;
	}
	
	public function testIsSearchEngineBotIp() {
		
		$this->assertFalse( DomBrowser::isSearchEngineBotIp(), 'Thinks we are search engine bot!');
		
		// test agains IP address
		
		$ips = DomBrowser::getSearchEngineIpAddresses();
		$ipCache = $_SERVER['REMOTE_ADDR'];
		
		$this->assertTrue( $ips != '', 'Ip list is empty' );
		$ips = explode("\r\n", $ips );
		$_SERVER['REMOTE_ADDR'] = $ips[0];

		$this->assertTrue( count($ips)>1500, 'There to too few ip addresses. Should be atleast 1500 but found only '.count($ips).'!');
		$this->assertTrue( DomBrowser::isSearchEngineBotIp(), 'Didn\'t reconize bot!');

		$_SERVER['REMOTE_ADDR'] = $ipCache;

	}
}
?>